<?xml version="1.0" encoding="UTF-8"?>
<html xst:version="0.2"
        xmlns       = "http://www.w3.org/1999/xhtml"
        xmlns:xst   = "http://code.google.com/p/xstag/ns/2011/"
        xmlns:books = "http://code.google.com/p/xstag/ns/example/books/"
        >
  <xst:import href="books-lib/books.xstag"/>
  <xst:variable name="years" select="('2000', '2001', '2008')"/>
  <xst:variable name="genres" select="('Fantasy', 'Romance', 'Computer')"/>
  <xst:variable name="booksByYear">
    <books:booksByYears>{$years}</books:booksByYears>
  </xst:variable>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Books for {$years} years</title>
  </head>
  <body>
    <books:dateTag xst:handles="$current-date">
      <div class="tableClass">
        <p>Generated on {$current-date}
           for {fn:count($booksByYear)} books
           in {fn:string-join($genres,", ")} genres
           during {fn:string-join($years,", ")} years</p>  
        <table>
          <books:htmlBooksByGenre>
            <books:genres>{$genres}</books:genres>
            <books:books>{$booksByYear}</books:books>
            <books:onTitle xst:handles="$title">
              <strong>{$title}</strong>
            </books:onTitle>
            <books:onBook xst:handles="$title, $authors">
              <tr>
                <td>{$title}</td>
                <td>{fn:string-join($authors, '; ')}</td>
                <td>{fn:count($authors)}</td>
              </tr>        
            </books:onBook>
          </books:htmlBooksByGenre>
        </table>
      </div>  
    </books:dateTag>
  </body>
</html>
